]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
PowerStatus: report 0 minutes as "Estimating..."
authorGiovanni Campagna <gcampagna@src.gnome.org>
Sat, 19 Feb 2011 14:40:53 +0000 (15:40 +0100)
committerGiovanni Campagna <gcampagna@src.gnome.org>
Tue, 1 Mar 2011 19:18:29 +0000 (20:18 +0100)
When UPower has not yet collected enough data to calculate a time
to discharge, it will report 0 minutes. Show "Estimating..." in
that case instead.

https://bugzilla.gnome.org/show_bug.cgi?id=642753

js/ui/status/power.js

index 94469334d4881f34e454faa3a33d444baa9cab2c..f3625cc2d2d041489712cec87c76aecfae7c8437 100644 (file)
@@ -104,21 +104,27 @@ Indicator.prototype = {
             if (device_type == UPDeviceType.BATTERY) {
                 this._hasPrimary = true;
                 let time = Math.round(seconds / 60);
-                let minutes = time % 60;
-                let hours = Math.floor(time / 60);
-                let timestring;
-                if (time > 60) {
-                    if (minutes == 0) {
-                        timestring = Gettext.ngettext("%d hour remaining", "%d hours remaining", hours).format(hours);
-                    } else {
-                        /* TRANSLATORS: this is a time string, as in "%d hours %d minutes remaining" */
-                        let template = _("%d %s %d %s remaining");
-
-                        timestring = template.format (hours, Gettext.ngettext("hour", "hours", hours), minutes, Gettext.ngettext("minute", "minutes", minutes));
-                    }
-                } else
-                    timestring = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes);
-                this._batteryItem.label.text = timestring;
+                if (time == 0) {
+                    // 0 is reported when UPower does not have enough data
+                    // to estimate battery life
+                    this._batteryItem.label.text = _("Estimating...");
+                } else {
+                    let minutes = time % 60;
+                    let hours = Math.floor(time / 60);
+                    let timestring;
+                    if (time > 60) {
+                        if (minutes == 0) {
+                            timestring = Gettext.ngettext("%d hour remaining", "%d hours remaining", hours).format(hours);
+                        } else {
+                            /* TRANSLATORS: this is a time string, as in "%d hours %d minutes remaining" */
+                            let template = _("%d %s %d %s remaining");
+
+                            timestring = template.format (hours, Gettext.ngettext("hour", "hours", hours), minutes, Gettext.ngettext("minute", "minutes", minutes));
+                        }
+                    } else
+                        timestring = Gettext.ngettext("%d minute remaining", "%d minutes remaining", minutes).format(minutes);
+                    this._batteryItem.label.text = timestring;
+                }
                 this._primaryPercentage.text = Math.round(percentage) + '%';
                 this._batteryItem.actor.show();
                 if (this._deviceItems.length > 0)